home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / lib / obsolete / student_t.pro < prev    next >
Text File  |  1997-07-08  |  1KB  |  60 lines

  1. ; $Id: student_t.pro,v 1.2 1997/01/15 04:02:19 ali Exp $
  2. ;
  3. ;  Copyright (c) 1991-1997, Research Systems Inc.  All rights
  4. ;  reserved. Unauthorized reproduction prohibited.
  5.  
  6. function student_t , a1, DF
  7. ;+
  8. ; NAME:
  9. ;    STUDENT_T
  10. ;
  11. ; PURPOSE:
  12. ;    STUDENT_T returns the cutoff value v such that
  13. ;
  14. ;        Probability(X > v) = a1
  15. ;
  16. ;    where X is a random variable from the Student t's distribution with
  17. ;    DF degrees of freedom.
  18. ;
  19. ; CATEGORY:
  20. ;    Statistics.
  21. ;
  22. ; CALLING SEQUENCE:
  23. ;    Result = STUDENT_T(A, DF)
  24. ;
  25. ; INPUT:
  26. ;    A1:    The probability for which a cutoff is desired.
  27. ;    DF:    The degrees of freedom
  28. ;
  29. ; OUTPUT: 
  30. ;    The cutoff value if a is beween 0 and 1 inclusively. Otherwise, -1.
  31. ;-
  32. a = a1 
  33. if (a gt 1 or a lt 0) then return,-1  
  34.  
  35. if ( a gt .5) THEN adjust =1 ELSE BEGIN
  36.    adjust = 0
  37.    a = 1.0 -a
  38. ENDELSE
  39.  
  40. if a1 eq 0 THEN return, 1.e12
  41. if a1 eq 1 THEn return,-1.e12
  42.  
  43. case 1 of
  44.  DF EQ 1: UP = 100 > (100 * .005/a1)
  45.  DF EQ 2: UP = 10 > (10 *.005/a1)
  46.  DF GT 2 and  DF LE 5: UP= 5 > (5*.005/a1)
  47.  DF GT 5 and DF LE 14: UP = 4 > (4 *.005/a1)
  48.  ELSE: UP = 3 > (3 *.005/a1)                
  49. ENDCASE
  50.  
  51.  while student1_t(UP, DF) LT a DO BEGIN
  52.       Below = UP
  53.       UP = 2*UP
  54.  ENDWHILE
  55. x = pd_bisection([a,DF],'student1_t',Up,0)
  56.  
  57. if (adjust) THEN  return, -x   $
  58. ELSE return,x
  59. end
  60.